var express = require('express');
var router = express.Router();
let fs = require('fs')
let path = require('path')
let axios = require('axios')

/* GET home page. */
router.get('/', async(req, res, next) => {
  console.log(__dirname, 'path')
  let num = fs.readFileSync(__dirname + '/num.text', 'utf-8');
  console.log(num);
  let numnew = parseInt(num) + 1
  fs.writeFileSync(__dirname + '/num.text', JSON.stringify(numnew));

  const resp = await axios.post('http://data.zz.baidu.com/urls?site=m.glack.net&token=O6zgkeYCpi0fKig2')
  console.log(resp, '百度收录 + 1')

  res.json({
    code: 1,
    msg: '记录成功',
    data: {
      num: num
    },
  });
});

module.exports = router;